package com.yida.gwj.common.enums;

import cn.hutool.core.util.ObjectUtil;

/**
 * 业务标识
 *
 * @author lqq
 */
public enum GwjBusinessFlagType {
    //
    INIT(1, "基础数据管理", "小区基础数据初始化"),
    ADD_BUILD(2, "基础数据管理", "小区数据新增楼栋"),
    SPLIT(3, "基础数据管理", "小区拆分"),
    MERGE(4, "基础数据管理", "小区合并"),
    UPDATE_BUILD(5, "基础数据管理", "小区客体数据更新"),
    FUNDS_SPLIT(6, "缴存业务管理", "维修资金分户（初始化）"),
    OWNER_DEPOSIT(7, "缴存业务管理", "业主缴存"),
    REFUND_COMPLETE(8, "缴存业务管理", "退多补差管理"),
    UNIT_DEPOSIT(9, "缴存业务管理", "单位批量缴费"),
//    EXPEND_OUTSIDE(100, "住宅专项维修资金", "公维金资金申请[外网]"),
//    EXPEND_PRE(101, "住宅专项维修资金", "公维金资金申请[内网][预受理]"),
//    EXPEND_FORMAL(102, "住宅专项维修资金", "公维金资金申请[内网][正式受理]"),
//    EXPEND_OUTSIDE_APPROPRIATE(103, "住宅专项维修资金", "公维金资金[拨付]申请[外网]"),
//    EXPEND_APPROPRIATE_PRE(104, "住宅专项维修资金", "公维金资金[拨付]申请[内网][预受理]"),
//    EXPEND_APPROPRIATE_FORMAL(105, "住宅专项维修资金", "公维金资金[拨付]申请[内网][正式受理]"),
//    EXPEND_OUTSIDE_URGENT(106, "住宅专项维修资金", "公维金资金[应急]申请[外网]"),
//    EXPEND_URGENT_PRE(107, "住宅专项维修资金", "公维金资金[应急]申请[内网][预受理]"),
//    EXPEND_URGENT_FORMAL(108, "住宅专项维修资金", "公维金资金[应急]申请[内网][正式受理]"),
//    EXPEND_OUTSIDE_URGENT_APPROPRIATE(109, "住宅专项维修资金", "公维金资金[应急][拨付]申请[外网]"),
//    EXPEND_URGENT_APPROPRIATE_PRE(110, "住宅专项维修资金", "公维金资金[应急][拨付]申请[内网][预受理]"),
//    EXPEND_URGENT_APPROPRIATE_FORMAL(111, "住宅专项维修资金", "公维金资金[应急][拨付]申请[内网][正式受理]"),


    EXPEND_OUTSIDE(10, "住宅专项维修资金", "公维金资金申请[外网]"),
    EXPEND_PRE(11, "住宅专项维修资金", "公维金资金申请[内网][预受理]"),
    EXPEND_FORMAL(12, "住宅专项维修资金", "公维金资金申请[内网][正式受理]"),
    EXPEND_OUTSIDE_APPROPRIATE(13, "住宅专项维修资金", "公维金资金[拨付]申请[外网]"),
    EXPEND_APPROPRIATE_PRE(14, "住宅专项维修资金", "公维金资金[拨付]申请[内网][预受理]"),
    EXPEND_APPROPRIATE_FORMAL(15, "住宅专项维修资金", "公维金资金[拨付]申请[内网][正式受理]"),
    EXPEND_OUTSIDE_URGENT(16, "住宅专项维修资金", "公维金资金[应急]申请[外网]"),
    EXPEND_URGENT_PRE(17, "住宅专项维修资金", "公维金资金[应急]申请[内网][预受理]"),
    EXPEND_URGENT_FORMAL(18, "住宅专项维修资金", "公维金资金[应急]申请[内网][正式受理]"),
    EXPEND_OUTSIDE_URGENT_APPROPRIATE(19, "住宅专项维修资金", "公维金资金[应急][拨付]申请[外网]"),
    EXPEND_URGENT_APPROPRIATE_PRE(20, "住宅专项维修资金", "公维金资金[应急][拨付]申请[内网][预受理]"),
    EXPEND_URGENT_APPROPRIATE_FORMAL(21, "住宅专项维修资金", "公维金资金[应急][拨付]申请[内网][正式受理]"),
    ;

    private final Integer code;
    private final String info;

    GwjBusinessFlagType(Integer code, String category, String info) {
        this.code = code;
        this.info = info;
    }

    public Integer getCode() {
        return code;
    }

    public static String getInfoByCode(Integer code) {
        for (GwjBusinessFlagType value : GwjBusinessFlagType.values()) {
            if (value.getCode().equals(code)) {
                return value.getInfo();
            }
        }
        return null;
    }


    public String getInfo() {
        return info;
    }

    public static GwjBusinessFlagType getEnumByCode(Integer code) {
        for (GwjBusinessFlagType value : GwjBusinessFlagType.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static GwjBusinessFlagType translate(Integer code) {
        for (GwjBusinessFlagType value : GwjBusinessFlagType.values()) {
            if (ObjectUtil.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 判断是否为外网业务
     *
     * @param bizFlagId
     * @return
     */
    public static boolean isOutSide(Integer bizFlagId) {
        boolean flag = false;
        switch (GwjBusinessFlagType.getEnumByCode(bizFlagId)) {
            case EXPEND_OUTSIDE:
            case EXPEND_OUTSIDE_APPROPRIATE:
            case EXPEND_OUTSIDE_URGENT:
            case EXPEND_OUTSIDE_URGENT_APPROPRIATE:
                flag = true;
                break;
            default:
                break;
        }
        return flag;
    }

}
